#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void main(){
    FILE *f=fopen("D:/Code/CandC++/C Programming/12month/12month20/1.txt","r");
    if (f==NULL) {
        printf("Error");
        return;
    }
    int c;
    char buffer[100];
    int numbers[100];
    int count = 0;
    int index = 0;
    
    rewind(f);
    while ((c=fgetc(f))!=EOF){
        
        if ('0'<=c&&c<='9'){
            buffer[index++]=c;
        }
        else if(index>0){
            buffer[index]='\0';
            numbers[count++]=atoi(buffer);
            index=0;
        }
    }
    if (index>0){
        buffer[index]='\0';
        numbers[count++]=atoi(buffer);
    }
    fclose(f);
    f=fopen("D:/Code/CandC++/C Programming/12month/12month20/1.txt","w");
    for (int i=0; i<count; i++){
        for (int j=count-1;j>i;j--){
            if (numbers[j]<numbers[j-1]){
                int temp=numbers[j];
                numbers[j]=numbers[j-1];
                numbers[j-1]=temp;
            }
        }
    }
    rewind(f);
    for (int i=0; i<count; i++){
        fprintf(f,"%d",numbers[i]);
        //printf("%d",numbers[i]);
        if (i!=count-1) {
            fprintf(f," ");
            //printf(" ");
        }
    }
    fprintf(f,"\n");
    fclose(f);
}